package com.igoal.entity;

import java.io.Serializable;

import javax.persistence.Embeddable;
import javax.persistence.ManyToOne;

@Embeddable
public class GoalCategoryPk implements Serializable{
	private static final long serialVersionUID = -8287288509883408902L;
	private Goal goal;
	private Category category;
	
	@ManyToOne
	public Goal getGoal() {
		return goal;
	}
	public void setGoal(Goal goal) {
		this.goal = goal;
	}
	@ManyToOne
	public Category getCategory() {
		return category;
	}
	public void setCategory(Category category) {
		this.category = category;
	}
	@Override
	public boolean equals(Object o) {
		if (this == o) return true;
        if (o == null || getClass() != o.getClass()) return false;
 
        GoalCategoryPk that = (GoalCategoryPk) o;
 
        if (category != null ? !category.equals(that.category) : that.category != null) return false;
        if (goal != null ? !goal.equals(that.goal) : that.goal != null) return false;
 
        return true;
	}
	
	@Override
	public int hashCode() {
		return this.category.hashCode()+this.goal.hashCode();
	}
}
